
<?php
	session_start(); // On démarre la session AVANT toute chose
?>
<?php
	if($_SESSION['acces']=='ok')
	{
		if($_GET['action']=='Rendre')
		{
			header('Location: rendre.php');
		}
		else
		{
			header('Location: emprunter.php?ref=\''.$_GET['ref']. '\'');
		}
	}
	else
	{?>
		<!DOCTYPE html>
		<html>
			<head>

				<meta charset="utf-8" />
				<link rel="stylesheet" href="style.css" />
				<title>Rechercher un livre</title>
			</head>
		 
			<body>
				<header>
					<table>
						<tr>
							<td>			
								<div id="titre_principal">
									<a href="index.php">
										<img src="livre.jpg" alt="Logo AEO" id="logo" />
									</a>
									<h1>AEO<br />Bibliothèque</h1>
								</div>			
							</td>
						</tr>
					</table>
				</header>
				<hr/>

				<div id="contenu_site">
					<h6><a href="index.php">Index</a> > Rechercher</h6>
						
					<p>Veuillez vous enregistrer</p>
					<form action="#" method="post">
						<p>
						<input type="text" name="id" />
						<input type="password" name="mdp" />
						<input type="submit" value="Valider" />
						</p>
					</form>
					<?php
						if(isset($_POST['id']) AND isset($_POST['mdp']))
						{
							if($_POST['id']=='user' AND $_POST['mdp']='aeobib')
							{
								$_SESSION['acces']='ok';
								if($_GET['action']=='Rendre')
								{
									header('Location: rendre.php');
								}
								else
								{
									header('Location: emprunter.php?ref=\''.$_GET['ref']. '\'');
								}
							}
						}
							
					?>
				</div>
				
				<hr/>
				<footer>
					<table>
						<tr>
							<td>			
								<div id="titre_footer">
									<h5>AEO Bibliothèque ~ Projet ISN 2012-2013<br />ANDRES Guillaume, ECKEL Patrick, OUADIR Guillaume</h5>
								</div>			
							</td>
						</tr>
					</table>
				</footer>
			</body>
		</html><?php
	}
?>